package test_map

import "fmt"

func DoMap() {
	fmt.Println("Map->>")

	var map1 map[string]string
	map1 = make(map[string]string)

	map1["china"] = "中国"
	map1["meiguo"] = "米国"

	map2 := make(map[string]string)
	map2["key"] = "建值"

	for k, v := range map1 {
		fmt.Println(k, v)
	}

	haveKey("china", map1)

	delete(map1, "china")

	haveKey("china", map1)

}

func haveKey(key string, map1 map[string]string) {
	value, ok := map1[key]
	if ok {
		fmt.Println("存在", value)
	} else {
		fmt.Println("不存在", value)
	}
}
